package com.carryduck.token;


/**
 * 维护用户token
 */
public class UserTokenManager {

    /**
     * 生成token
     * @param userId 用户id
     * @return token
     */
	public static String generateToken(String userId) {
        JwtHelper jwtHelper = new JwtHelper();
        return jwtHelper.createToken(userId);
    }

    /**
     * 解析tone
     * @param token token字符串
     * @return userId
     */
    public static String getUserId(String token) {
    	JwtHelper jwtHelper = new JwtHelper();
        String userId = jwtHelper.verifyTokenAndGetUserId(token);
    	if(userId == null || "".equals(userId) ){
    		return null;
    	}
        return userId;
    }
}
